/*package com.zcsy.commons.util;

import java.util.SortedMap;
import java.util.TreeMap;

import org.apache.log4j.chainsaw.Main;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;
import com.zcsy.shop.model.wxpay.WxPayNotifyData;
import com.zcsy.shop.model.wxpay.WxPayReturnData;
import com.zcsy.shop.model.wxpay.WxPaySendData;

*//**
 * @Title: WeChatPayUtils.java
 * @Package： com.zcsy.commons.util
 * @Description: 微信支付帮助类
 *
 * @author tanghan barbadosliy@163.com
 * @Copyright: 2015 武汉中财数元信息技术有限公司 All rights reserved.
 * @date 2015年11月4日
 * @version 1.0
 * @see JDK1.7.0_75
 * @since
 *//*
public class WeChatPayUtils {

	private final static Logger logger = LoggerFactory.getLogger(WeChatPayUtils.class);

	*//**
	 * 交易用的API密钥<br>
	 *//*
	public static final String KEY = "lfshrefy4783ybrv3wunxwvr43ytv984";

	*//**
	 * 商户ID<br>
	 *//*
	public static final String MCH_ID = "1269363901";

	*//**
	 * @Description 统一下单接口<br>
	 * 
	 * @param data
	 * @param key
	 * @return
	 * @author tanghan barbadosliy@163.com
	 * @date 2015年11月4日
	 * @see
	 *//*
	public static WxPayReturnData unifiedOrder(WxPaySendData data) {
		WxPayReturnData returnData = null;
		// 统一下单支付
		String returnXml = null;
		try {
			
			//下单接口全局参数，下面参数可不修改
			PropertiesUtil util = new PropertiesUtil("config.properties");
			
			if(data.getSpbill_create_ip()==null){
				data.setSpbill_create_ip("113.57.254.115");
			}
			data.setNotify_url("http://m.cjfygift.com/buildOrder/notifyUrl");
//			data.setFee_type("CNY");
			data.setTrade_type("JSAPI");
			data.setNonce_str(WeChatUtils.create_nonce_str());
			data.setMch_id(MCH_ID);
			data.setAttach("微信支付");
			data.setAppid(util.getProperty("appId"));
//			data.setDevice_info("WeChat");
			
			// 生成sign签名
			SortedMap<Object, Object> parameters = new TreeMap<Object, Object>();
			  parameters.put("appid", data.getAppid()); 
			  parameters.put("mch_id", data.getMch_id());
			  parameters.put("nonce_str", data.getNonce_str());
		      parameters.put("attach", data.getAttach());
		      parameters.put("body", data.getBody());
		      parameters.put("detail", data.getDetail());
		      parameters.put("out_trade_no", data.getOut_trade_no());
		      
		      parameters.put("total_fee", data.getTotal_fee());
		      parameters.put("spbill_create_ip", data.getSpbill_create_ip());
		      parameters.put("notify_url", data.getNotify_url());
		      parameters.put("trade_type", data.getTrade_type());
		      parameters.put("openid", data.getOpenid());
		      
			 data.setSign(WeChatUtils.createSign(parameters, KEY));
			 XStream xs = new XStream(new DomDriver("UTF-8",new XmlFriendlyNameCoder("-_", "_")));
			 xs.alias("xml", WxPaySendData.class);
			 String xml = xs.toXML(data);
			 logger.error("统一下单xml为:\n" + xml);

			 returnXml =  HttpUtil.sendPostUrl("https://api.mch.weixin.qq.com/pay/unifiedorder", xml,HttpUtil.UTF8 );
			 logger.error("unifiedOrder:" + returnXml);
			 
			 XStream xStream = new XStream(new DomDriver());
		     xStream.processAnnotations(WxPayReturnData.class);
		     returnData = (WxPayReturnData) xStream.fromXML(returnXml);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return returnData;
	}

	public static void main(String[] args) {
//		WxPaySendData data = new WxPaySendData();
		
//		data.setDevice_info("WeChat");
//		data.setNonce_str("j76j2kkgnh2t1rbm");
//		data.setBody("邢粮梳篦-四大美女");
//		data.setDetail("邢粮梳篦-四大美女");
//		
//		data.setOut_trade_no("ddcf201511090009");
//		data.setTotal_fee(1);
//		data.setSpbill_create_ip("223.104.20.102");
//		data.setNotify_url("http://www.weixin.qq.com/wxpay/pay.php");
//		// 限制不许信用卡支付
//
//		data.setOpenid("o1rY0wz51vilK_6k8ofEEzUtRjsQ");
//
//		WxPayReturnData wx = unifiedOrder(data);
//		System.out.println(wx.getReturn_code());
//		System.out.println(wx.getReturn_msg());
		
		
		String notify = "<xml><appid><![CDATA[wx18dee29515d4402b]]></appid><attach><![CDATA[微信支付]]></attach><bank_type><![CDATA[CFT]]></bank_type><cash_fee><![CDATA[1]]></cash_fee><fee_type><![CDATA[CNY]]></fee_type><is_subscribe><![CDATA[Y]]></is_subscribe><mch_id><![CDATA[1269363901]]></mch_id><nonce_str><![CDATA[mcugmfirfprlhmmp]]></nonce_str><openid><![CDATA[o1rY0wz51vilK_6k8ofEEzUtRjsQ]]></openid><out_trade_no><![CDATA[ddcf201511140034]]></out_trade_no><result_code><![CDATA[SUCCESS]]></result_code><return_code><![CDATA[SUCCESS]]></return_code><sign><![CDATA[A5C5EC7A8BE4CC7E9A1BFB872D9FF4F4]]></sign><time_end><![CDATA[20151114172343]]></time_end><total_fee>1</total_fee><trade_type><![CDATA[JSAPI]]></trade_type><transaction_id><![CDATA[1000950334201511141601401989]]></transaction_id></xml>";
		XStream xStream = new XStream(new DomDriver());
	     xStream.processAnnotations(WxPayNotifyData.class);
	     WxPayNotifyData returnData = (WxPayNotifyData) xStream.fromXML(notify);
	     System.out.println(returnData.toString());
	}
}
*/